let s = "anagram", t = "nagaram"
var isAnagram = function(s, t) {
    let obj = new Map()
    for(let i=0;i<s.length;i++){
        if(obj.has(s[i])){
            obj.set(s[i],obj.get(s[i])+1)
        }else{
            obj.set(s[i],1)
        }
    }
    for(let j=0;j<t.length;j++){
        if(!(obj.has(t[j]))){
            return false
        }
        obj.set(t[j],obj.get(t[j])-1)
        if(obj.get(t[j])<0){
            return false
        }
    }
    
     for(let item of obj){
        console.log(item[1]);
        if(item[1]!==0){
            return false;
        } 
    } 
    return true
};
console.log(isAnagram(s,t));
